import request from '@/utils/request'
import defaultSettings from '@/settings'

// 列表
export function searchDictData(query) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/dictInfo/searchDictData`,
    method: 'get',
    params: query
  })
}

// 根据字典类型查询字典数据信息
export function getDicts(dictType) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/enum/findEnumByType?type=${dictType}`,
    method: 'get'
  })
}

export function getDictsList(typeList) {
  //?typeList=${typeList.join(',')}
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/enum/findEnumsByTypes?types=${typeList.join(',')}`,
    method: 'post',
  })
}

// 查询字典数据详细
export function getData(id) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/dictInfo/getDictDataInfo?id=` + id,
    method: 'get'
  })
}

// 新增或编辑字典数据
export function saveOrUpdateData(data) {
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/dictInfo/saveData`,
    method: 'post',
    data: data
  })
}

// 删除字典数据
export function delData(ids) {

  const data = (ids && ids.indexOf(',') > -1) ? ids.join(',') : ids;
  return request({
    url: `${defaultSettings.ctx.authorityApp}/s/dictInfo/removeData?ids=${ids ? data : ''}`,
    method: 'post'
  })
}
